using System.Collections;
using FlowCanvas;
using FlowCanvas.Nodes;

namespace Yoozoo.Gameplay.Liberty.Nodes
{
    public class Switch2HangingScene : LatentActionNodeBase
    {
        private bool finish = false;
        public override bool allowRoutineQueueing { get { return false; } }
        
        public IEnumerator Invoke(string mark)
        {
            finish = false;
            BlueprintUtils.Switch2HangingScene(OnFinish,mark);
            yield return new UnityEngine.WaitUntil(() =>
            {
                return finish;
            });
        }

        private void OnFinish()
        {
            finish = true;
        }
        
        protected override void OnRegisterDerivedPorts(FlowNode node)
        {
            var p1 = node.AddValueInput<string>("mark");
        
            node.AddFlowInput("In", (f) => { Begin(Invoke(p1.value), f); });
        }
        
    }
}